package com.mcxx.convert;

import com.mcxx.common.exception.BizException;
import com.mcxx.modules.miniSalvation.fundpay.dto.FundPayFamilyDTO;
import com.mcxx.modules.miniSalvation.fundpay.entity.*;
import com.mcxx.modules.miniSalvation.salary.entity.FamilySalaryEntity;
import com.mcxx.modules.miniSalvation.salary.entity.MemberSalaryEntity;
import com.mcxx.util.Constant;
import com.mcxx.util.DateUtil;

import java.text.ParseException;
import java.util.Date;


public class FamilySalaryConvert {


    public static MemberSalaryEntity convertMemberSalaryEntity(FundPayMemberEntity fundPayMemberEntity, FundPayEntity fundPayEntity){
        MemberSalaryEntity memberSalaryEntity = new MemberSalaryEntity();

        memberSalaryEntity.setId(Constant.getUUID());

        memberSalaryEntity.setOrderId(fundPayMemberEntity.getOrderId());

        memberSalaryEntity.setStartDate(fundPayEntity.getPayDate());

        memberSalaryEntity.setEndDate(fundPayEntity.getPayDate());

        memberSalaryEntity.setInputDate(DateUtil.getMonthString());

        memberSalaryEntity.setSalaryNumber(fundPayMemberEntity.getFundNumber());

        memberSalaryEntity.setSalaryType(Constant.SalaryType.CUSTOM_FUND_PAY_REISSUE);

        memberSalaryEntity.setFamilyId(fundPayMemberEntity.getFamilyId());

        memberSalaryEntity.setMemberId(fundPayMemberEntity.getMemberId());

        memberSalaryEntity.setBusinessType(fundPayEntity.getBusinessType());

        memberSalaryEntity.setRemark(fundPayMemberEntity.getRemark());

        memberSalaryEntity.setAreaCode(fundPayMemberEntity.getAreaCode());

        memberSalaryEntity.setCountyCode(fundPayMemberEntity.getAreaCode().substring(0,6));

        memberSalaryEntity.setUpdateDate(new Date());

        memberSalaryEntity.setRuleId(fundPayMemberEntity.getId());

        memberSalaryEntity.setItemType(fundPayEntity.getCostType());

        memberSalaryEntity.setSaveReason("自定义补发补助金额");
        return memberSalaryEntity;
    }


    public static FamilySalaryEntity convertFamilySalaryEntity(FundPayFamilyDTO fundPayFamily, FundPayEntity fundPayEntity) {
        FamilySalaryEntity familySalaryEntity = new FamilySalaryEntity();

        familySalaryEntity.setId(Constant.getUUID());

        familySalaryEntity.setOrderId(fundPayFamily.getOrderId());

        familySalaryEntity.setStartDate(fundPayEntity.getPayDate());

        familySalaryEntity.setEndDate(fundPayEntity.getPayDate());

        familySalaryEntity.setInputDate(DateUtil.getMonthString());

        familySalaryEntity.setSalaryNumber(fundPayFamily.getFundNumber());

        familySalaryEntity.setSalaryType(Constant.SalaryType.CUSTOM_FUND_PAY_REISSUE);

        familySalaryEntity.setFamilyId(fundPayFamily.getFamilyId());

        familySalaryEntity.setBusinessType(fundPayEntity.getBusinessType());

        familySalaryEntity.setRemark(fundPayEntity.getRemark());

        familySalaryEntity.setAreaCode(fundPayEntity.getAreaCode());

        familySalaryEntity.setCountyCode(fundPayEntity.getAreaCode().substring(0,6));

        familySalaryEntity.setUpdateTime(new Date());

        familySalaryEntity.setCreateTime(new Date());

        familySalaryEntity.setWelfareId(fundPayFamily.getId());

        familySalaryEntity.setIdcard(fundPayFamily.getIdcard());

        familySalaryEntity.setChangeTime(new Date());

        familySalaryEntity.setChangeType(Constant.FamilySalaryChangeType.CHANGE);

        familySalaryEntity.setSaveReason("自定义补发补助金额");

        return familySalaryEntity;
    }


}

